#ifdef ARDUINO
#include <Arduino.h>
#include "SPI.h"
#include <core_debug.h>
#endif
#include <spiffs.h>
#include <SPIFlash.h>
class FlashFs
{
public:
    FlashFs(){};
#ifdef ARDUINO
    void begin(SPIClass *spi, uint8_t cs);
#else
    void begin(SPI_HandleTypeDef *spi, GPIO_TypeDef *, uint16_t);
#endif
void mount();
    void format();
    u32_t used_space, total;
    int info();
    void dir();
    u32_t flash_size();
    u32_t flash_chip_code();

private:
#ifdef ARDUINO
    SPIClass *spi;
#else
    SPI_HandleTypeDef *spi;
#endif
};

class FlashFile
{
public:
    FlashFile();
    int open_rdonly(const char *filename);
    int open_write(const char *filename);   //写文件,文件不存在则创建,覆盖旧数据
    int read(char *buf, int len);
    int write(const char *buf, int len);
    int close();
    int remove();
    int size();
    int eof();
    int fseek(int, int);
    int rewind();
    int fflush();
    spiffs_file fd;
    const char *filename;
    static int stat(const char *filename);

private:
};
int flash_rename(const char *, const char *);
extern spiffs fs;